import os
import sys
import django
from django.conf import settings
if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "luffy.settings.dev")
    django.setup()

    from libs.ipay import alipay,alipay_gateway

    subject = u"测试订单".encode("utf8")
    # For Python 3 users, just use the default string
    subject = "测试订单"

    # Pay via Web，open this url in your browser: https://openapi.alipay.com/gateway.do? + order_string
    order_string = alipay.api_alipay_trade_page_pay(
        out_trade_no='2016101600696641',
        total_amount=0.01,
        subject=subject,
        return_url=settings.LUFFY_URL,
        notify_url=settings.BASE_URL  # this is optional
    )

    print(order_string)
    # pay_url = alipay_gateway + order_string
    #
    # print(pay_url)